<template>
	<div class="page">
		<c-title :hide="false" text=" 我的易货"></c-title>
		<van-tabs v-model:active="active" @change="changetabs">
			<van-tab title="已审核"></van-tab>
			<van-tab title="待审核"></van-tab>
		</van-tabs>
		<div class="content">
			<div class="list" v-for="(item,index) in list" :key="index" @click="gopage(item.id)">
				<div class="top">
					<div class="img_left">
						<img :src="item.goods_pic" alt="">
					</div>
					<div class="r">
						<div class="item">
							<div class="lab">姓名：</div>
							<div class="text">
								{{item.name}}1
							</div>
						</div>
						<div class="item">
							<div class="lab">品牌：</div>
							<div class="text">
								{{item.goods_brand}}
							</div>
						</div>
						<div class="item">
							<div class="lab">介绍：</div>
							<div class="text">
								{{item.goods_desc}}
							</div>
						</div>
						<div class="item">
							<div class="lab">价格：</div>
							<div class="text">
								{{item.goods_price}}
							</div>
						</div>
					</div>
				</div>
				<div class="bot">
					<div class="bl">
						
					</div>
					<div class="br">
						<div class="sj" v-if="item.status ==0"  @click.stop="sj(item.id)">
							上架
						</div>
						<div class="xj" v-if="item.status ==1"  @click.stop="xj(item.id)">
							下架
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import { Toast } from "vant";
	export default {
		data() {
			return {
				active: 0,
				list: []
			}
		},
		activated() {
			this.getlist()
		},
		methods: {
			sj(id){
				$http.get('plugin.hft-yh.api.shop.shangjia', {
					goods_id: id
				}).then(response => {
					if(response.result ==1){
						Toast('上架成功！')
						this.getlist()
					}
				
				}).catch(error => {
					console.log(error);
				});
				
			},
			xj(id){
				$http.get('plugin.hft-yh.api.shop.xiajia', {
					goods_id: id
				}).then(response => {
					if(response.result ==1){
						Toast('下架成功！')
						this.getlist()
					}
				
				}).catch(error => {
					console.log(error);
				});
				
			},
			gopage(id) {
				console.log(id)
				this.$router.push(this.fun.getUrl("yhdetail", {
					id,
					store_id: this.$route.params.store_id
				},{
					id,
					store_id: this.$route.params.store_id
				}
				));
			},
			getlist() {
				$http.get('plugin.hft-yh.api.shop.getlist', {
					check_status: this.active
				}).then(response => {
					this.list = response.data
					console.log(this.list);

				}).catch(error => {
					console.log(error);
				});
			},
			changetabs(e) {
				console.log(e)
				this.active = e
				this.getlist()
			}
		}
	}
</script>

<style scoped lang="scss">
	.page {
		.content {
			.list {
				background-color: #fff;
				margin-bottom: 0.3rem;
				padding: 0.5rem;
				.bot {
						display: flex;
						justify-content: space-between;
						.br{
							display: flex;
							.sj{
								background-color: #25AEF3;
								color: #fff;
								padding: 0.5rem 1rem;
								border-radius: 0.5rem;
								margin-right: 0.5rem	;
							}
							.xj{
								background-color: #E63E31;
								color: #fff;
								padding: 0.5rem 1rem;
								border-radius: 0.5rem;
							}
						}
				}
				.top {
					display: flex;

					.img_left {
						margin-right: 0.52rem;

						img {
							width: 6rem;
							height: 6rem;
						}
					}

					.r {
						

						.item {
							display: flex;
							line-height: 1.5rem;
						}
					}
				}

			}
		}
	}
</style>
